package com.cloud.bssp.monitor.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cloud.bssp.monitor.convert.DruidMonitorDoConvert;
import com.cloud.bssp.monitor.dto.DruidMonitorDTO;
import com.cloud.bssp.monitor.entity.DruidMonitorDO;
import com.cloud.bssp.monitor.service.DruidMonitorService;
import com.cloud.bssp.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description: druid监控
 * Create Date: 2021-03-30T14:06:36.337
 * Modified By：<br>
 * Modified Date：<br>
 * Why & What is modified：<br>
 *
 * @author weirx
 * @version 1.0
 */
@Api(tags = "druid监控")
@RestController
@RequestMapping("/druid/monitor")
@AllArgsConstructor
public class DruidMonitorController {

    /**
     * DruidMonitorService
     */
    private DruidMonitorService druidMonitorService;

    /**
     * 分页列表
     *
     * @param druidMonitorDTO
     * @return
     */
    @ApiOperation(value = "分页列表")
    @PostMapping("/pageList")
    public R pageList(@RequestBody DruidMonitorDTO druidMonitorDTO) {
        Page<DruidMonitorDO> page = new Page<>(druidMonitorDTO.getPage(), druidMonitorDTO.getLimit());
        Page<DruidMonitorDO> pageList = druidMonitorService.page(page);
        return R.success(DruidMonitorDoConvert.pageConvert(pageList));
    }
}